package route

import (
	"github.com/gin-gonic/gin"
	controllerAnts "go-member/controller/ants"
	controllerCategory "go-member/controller/category"
	controllerIndex "go-member/controller/index"
	controllerLogin "go-member/controller/login"
	"go-member/midd"
)

// V1
// @Description:API路由
func V1() {
	router := gin.Default()

	// 不需要授权登录
	v1 := router.Group("/api/v1/")
	{
		v1.POST("login", controllerLogin.Login()) //登录
		v1.POST("jwt", controllerIndex.Jwt())     //jwt
		v1.POST("ants", controllerAnts.Ants())    //ants娱乐
	}

	//  需要授权登录
	v1Auth := router.Group("/api/v1/auth/")
	v1Auth.Use(midd.CheckLogin()) //路由中间件
	{
		v1Auth.GET("user-list", controllerIndex.UserList())            //用户列表
		v1Auth.POST("add-user", controllerIndex.AddUser())             //新增用户
		v1Auth.POST("update-number", controllerIndex.UpdateNumber())   //修改次数[增加|减少]
		v1Auth.POST("invest", controllerIndex.Invest())                //充值
		v1Auth.POST("del-user", controllerIndex.DelUser())             //删除列表(软删除)
		v1Auth.POST("recover-user", controllerIndex.RecoverUser())     //恢复
		v1Auth.POST("edit-user", controllerIndex.EditUser())           //编辑
		v1Auth.GET("category-list", controllerCategory.CategoryList()) //分类列表
		v1Auth.POST("add-category", controllerCategory.AddCategory())  //添加分类
		v1Auth.GET("invest-list", controllerIndex.InvestList())        //充值记录
		v1Auth.GET("number-list", controllerIndex.NumberList())        //次数加减记录
	}

	router.Run(":9000")
}
